var elementIdToFocus = "undefined";

function focusStartPage() {
	if (elementIdToFocus != "undefined" && window.document.getElementById) {
		window.document.getElementById(elementIdToFocus).focus();
		return;
	}

	for ( var f = 0; f <= window.document.forms.length - 1; f++) {
		form = window.document.forms[f];

		// verifica campos do form
		for ( var i = 0; i <= form.length - 1; i++) {
			if (!form.elements[i].disabled) {
				if (form.elements[i].type == "select-one"
						|| (form.elements[i].type == "text" && !form.elements[i].value)) {
					form.elements[i].focus();
					return;
				}
			}
		}
	}
}

if (window.addEventListener) {
	window.addEventListener("load", focusStartPage, true);
} else {
	if (window.attachEvent) {
		window.attachEvent("onload", focusStartPage);
	}
}

/**
 * Se n�o quiser dar foco ao primeiro campo texto da tela, deve ser utilizado
 * este m�todo para falar qual id do campo que deve se dar foco ao entrar na
 * tela.
 */
function defineElementIdToFocus(idToFocus) {
	elementIdToFocus = idToFocus;
}